/**
 * @file name ToastUtils.java
 */
package com.digital.community.common.utils;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.digital.community.R;

/**
 * 
 * @author yarine.gao
 * @date 2012-4-27
 * @version 1.0.0
 */
public class ToastUtils {

	public static void showErrorToast(Context context, LayoutInflater inflater, String content, boolean duration) {
		Toast toast = Toast.makeText(context, null, duration ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT);
		
		View view = inflater.inflate(R.layout.toast_error, null);
		TextView text = (TextView)view.findViewById(R.id.content);
		text.setText(content);
		
		toast.setView(view);
		toast.show();
	}
	
	public static void showWarningToast(Context context, LayoutInflater inflater, String content, boolean duration) {
		Toast toast = Toast.makeText(context, null, duration ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT);
		
		View view = inflater.inflate(R.layout.toast_warning, null);
		TextView text = (TextView)view.findViewById(R.id.content);
		text.setText(content);
		
		toast.setView(view);
		toast.show();
	}
	
	public static void showTrueToast(Context context, LayoutInflater inflater, String content, boolean duration) {
		Toast toast = Toast.makeText(context, null, duration ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT);
		
		View view = inflater.inflate(R.layout.toast_true, null);
		TextView text = (TextView)view.findViewById(R.id.content);
		text.setText(content);
		
		toast.setView(view);
		toast.show();
	}
}
